<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>kubectl-Command-Markmap</title>
<style>
* {
  margin: 0;
  padding: 0;
}
#mindmap {
  display: block;
  width: 100vw;
  height: 100vh;
}
</style>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/markmap-toolbar@0.1.5/dist/style.min.css">
</head>
<body>
<svg id="mindmap"></svg>
<script src="https://cdn.jsdelivr.net/npm/d3@6.6.0"></script><script src="https://cdn.jsdelivr.net/npm/markmap-view@0.2.3"></script><script src="https://cdn.jsdelivr.net/npm/markmap-toolbar@0.1.5/dist/index.umd.min.js"></script><script>(r => {
                setTimeout(r);
              })(() => {
  const {
    markmap,
    mm
  } = window;
  const toolbar = new markmap.Toolbar();
  toolbar.attach(mm);
  const el = toolbar.render();
  el.setAttribute('style', 'position:absolute;bottom:20px;right:20px');
  document.body.append(el);
})</script><script>((getMarkmap, getOptions, data) => {
        const {
          Markmap
        } = getMarkmap();
        window.mm = Markmap.create('svg#mindmap', getOptions == null ? void 0 : getOptions(), data);
      })(() => window.markmap,null,{"t":"heading","d":1,"p":{"lines":[0,1]},"v":"kubctl命令","c":[{"t":"heading","d":2,"p":{"lines":[1,2]},"v":"基础命令：create，delete，get，run，expose，set，explain，edit","c":[{"t":"heading","d":3,"p":{"lines":[2,3]},"v":"<strong>create 命令</strong>：根据文件或者输入来创建资源","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 创建Deployment和Service资源</span>\n$ kubectl create -f demo-deployment.yaml\n$ kubectl create -f demo-service.yaml\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[9,10]},"v":"delete 命令**：删除资源","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 根据yaml文件删除对应的资源，但是yaml文件并不会被删除，这样更加高效</span>\n$ kubectl delete -f demo-deployment.yaml \n$ kubectl delete -f demo-service.yaml\n<span class=\"token comment\"># 也可以通过具体的资源名称来进行删除，使用这个删除资源，同时删除deployment和service资源</span>\n$ kubectl delete 具体的资源名称\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[18,19]},"v":"<strong>get 命令</strong> ：获得资源信息","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 查看所有的资源信息</span>\n$ kubectl get all\n$ kubectl get --all-namespaces\n\n<span class=\"token comment\"># 查看pod列表</span>\n$ kubectl get pod\n\n<span class=\"token comment\"># 显示pod节点的标签信息</span>\n$ kubectl get pod --show-labels\n\n<span class=\"token comment\"># 根据指定标签匹配到具体的pod</span>\n$ kubectl get pods -l <span class=\"token assign-left variable\">app</span><span class=\"token operator\">=</span>example\n\n<span class=\"token comment\"># 查看node节点列表</span>\n$ kubectl get node \n\n<span class=\"token comment\"># 显示node节点的标签信息</span>\n$ kubectl get node --show-labels\n\n<span class=\"token comment\"># 查看pod详细信息，也就是可以查看pod具体运行在哪个节点上（ip地址信息）</span>\n$ kubectl get pod -o wide\n\n<span class=\"token comment\"># 查看服务的详细信息，显示了服务名称，类型，集群ip，端口，时间等信息</span>\n$ kubectl get svc\n$ kubectl get svc -n kube-system\n\n<span class=\"token comment\"># 查看命名空间</span>\n$ kubectl get ns\n$ kubectl get namespaces\n\n<span class=\"token comment\"># 查看所有pod所属的命名空间</span>\n$ kubectl get pod --all-namespaces\n\n<span class=\"token comment\"># 查看所有pod所属的命名空间并且查看都在哪些节点上运行</span>\n$ kubectl get pod --all-namespaces  -o wide\n\n<span class=\"token comment\"># 查看目前所有的replica set，显示了所有的pod的副本数，以及他们的可用数量以及状态等信息</span>\n$ kubectl get rs\n\n<span class=\"token comment\"># 查看已经部署了的所有应用，可以看到容器，以及容器所用的镜像，标签等信息</span>\n$ kubectl get deploy -o wide\n$ kubectl get deployments -o wide\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[66,67]},"v":"<strong>run 命令</strong>：在集群中创建并运行一个或多个容器镜像。","c":[{"t":"blockquote","d":4,"p":{"lines":[68,69]},"v":"","c":[{"t":"paragraph","d":5,"p":{"lines":[68,69]},"v":"<code>语法</code>：run NAME --image=image [--env=&quot;key=value&quot;] [--port=port] [--replicas=replicas] [--dry-run=bool] [--overrides=inline-json] [--command] -- [COMMAND] [args...]"}]},{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 示例，运行一个名称为nginx，副本数为3，标签为app=example，镜像为nginx:1.10，端口为80的容器实例</span>\n$ kubectl run nginx --replicas<span class=\"token operator\">=</span><span class=\"token number\">3</span> --labels<span class=\"token operator\">=</span><span class=\"token string\">\"app=example\"</span> --image<span class=\"token operator\">=</span>nginx:1.10 --port<span class=\"token operator\">=</span><span class=\"token number\">80</span>\n\n<span class=\"token comment\"># 示例，运行一个名称为nginx，副本数为3，标签为app=example，镜像为nginx:1.10，端口为80的容器实例，并绑定到k8s-node1上</span>\n$ kubectl run nginx --image<span class=\"token operator\">=</span>nginx:1.10 --replicas<span class=\"token operator\">=</span><span class=\"token number\">3</span> --labels<span class=\"token operator\">=</span><span class=\"token string\">\"app=example\"</span> --port<span class=\"token operator\">=</span><span class=\"token number\">80</span> --overrides<span class=\"token operator\">=</span><span class=\"token string\">'{\"apiVersion\":\"apps/v1\",\"spec\":{\"template\":{\"spec\":{\"nodeSelector\":{\"kubernetes.io/hostname\":\"k8s-node1\"}}}}}'</span>\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[78,79]},"v":"<strong>expose 命令</strong>：创建一个service服务，并且暴露端口让外部可以访问","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 创建一个nginx服务并且暴露端口让外界可以访问</span>\n$ kubectl expose deployment nginx --port<span class=\"token operator\">=</span><span class=\"token number\">88</span> --type<span class=\"token operator\">=</span>NodePort --target-port<span class=\"token operator\">=</span><span class=\"token number\">80</span> --name<span class=\"token operator\">=</span>nginx-service\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[85,86]},"v":"<strong>set 命令</strong>：配置应用的一些特定资源，也可以修改应用已有的资源","c":[{"t":"blockquote","d":4,"p":{"lines":[87,88]},"v":"","c":[{"t":"paragraph","d":5,"p":{"lines":[87,88]},"v":"使用 <code>kubectl set --help</code>查看，它的子命令，<code>env</code>，<code>image</code>，<code>resources</code>，<code>selector</code>，<code>serviceaccount</code>，<code>subject</code>。"}]},{"t":"blockquote","d":4,"p":{"lines":[89,90]},"v":"","c":[{"t":"paragraph","d":5,"p":{"lines":[89,90]},"v":"<code>语法</code>：resources (-f FILENAME | TYPE NAME) ([--limits=LIMITS &amp; --requests=REQUESTS]"}]},{"t":"heading","d":4,"p":{"lines":[93,94]},"v":"kubectl set resources 命令","c":[{"t":"fence","d":5,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 将deployment的nginx容器cpu限制为“200m”，将内存设置为“512Mi”</span>\n$ kubectl <span class=\"token builtin class-name\">set</span> resources deployment nginx -c<span class=\"token operator\">=</span>nginx --limits<span class=\"token operator\">=</span>cpu<span class=\"token operator\">=</span>200m,memory<span class=\"token operator\">=</span>512Mi\n\n<span class=\"token comment\"># 设置所有nginx容器中 Requests和Limits</span>\n$ kubectl <span class=\"token builtin class-name\">set</span> resources deployment nginx --limits<span class=\"token operator\">=</span>cpu<span class=\"token operator\">=</span>200m,memory<span class=\"token operator\">=</span>512Mi --requests<span class=\"token operator\">=</span>cpu<span class=\"token operator\">=</span>100m,memory<span class=\"token operator\">=</span>256Mi\n\n<span class=\"token comment\"># 删除nginx中容器的计算资源值</span>\n$ kubectl <span class=\"token builtin class-name\">set</span> resources deployment nginx --limits<span class=\"token operator\">=</span>cpu<span class=\"token operator\">=</span><span class=\"token number\">0</span>,memory<span class=\"token operator\">=</span><span class=\"token number\">0</span> --requests<span class=\"token operator\">=</span>cpu<span class=\"token operator\">=</span><span class=\"token number\">0</span>,memory<span class=\"token operator\">=</span><span class=\"token number\">0</span>\n</code></pre>\n"}]},{"t":"heading","d":4,"p":{"lines":[118,119]},"v":"kubectl set selector 命令","c":[{"t":"paragraph","d":6,"p":{"lines":[126,127]},"v":"<code>语法</code>：selector (-f FILENAME | TYPE NAME) EXPRESSIONS [--resource-version=version]"}]},{"t":"heading","d":4,"p":{"lines":[128,129]},"v":"kubectl set image 命令","c":[{"t":"blockquote","d":5,"p":{"lines":[134,135]},"v":"","c":[{"t":"paragraph","d":6,"p":{"lines":[134,135]},"v":"<code>语法</code>：image (-f FILENAME | TYPE NAME) CONTAINER_NAME_1=CONTAINER_IMAGE_1 ... CONTAINER_NAME_N=CONTAINER_IMAGE_N"}]},{"t":"fence","d":5,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 将deployment中的nginx容器镜像设置为“nginx：1.9.1”</span>\n$ kubectl <span class=\"token builtin class-name\">set</span> image deployment/nginx <span class=\"token assign-left variable\">busybox</span><span class=\"token operator\">=</span>busybox <span class=\"token assign-left variable\">nginx</span><span class=\"token operator\">=</span>nginx:1.9.1\n\n<span class=\"token comment\"># 所有deployment和rc的nginx容器镜像更新为“nginx：1.9.1”</span>\n$ kubectl <span class=\"token builtin class-name\">set</span> image deployments,rc <span class=\"token assign-left variable\">nginx</span><span class=\"token operator\">=</span>nginx:1.9.1 --all\n\n<span class=\"token comment\"># 将daemonset abc的所有容器镜像更新为“nginx：1.9.1”</span>\n$ kubectl <span class=\"token builtin class-name\">set</span> image daemonset abc *<span class=\"token operator\">=</span>nginx:1.9.1\n\n<span class=\"token comment\"># 从本地文件中更新nginx容器镜像</span>\n$ kubectl <span class=\"token builtin class-name\">set</span> image -f path/to/file.yaml <span class=\"token assign-left variable\">nginx</span><span class=\"token operator\">=</span>nginx:1.9.1 --local -o yaml\n</code></pre>\n"}]}]},{"t":"heading","d":3,"p":{"lines":[150,151]},"v":"<strong>explain 命令</strong>：用于显示资源文档信息","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\">$ kubectl explain rs\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[154,155]},"v":"<strong>edit 命令</strong>: 用于编辑资源信息","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 编辑Deployment nginx的一些信息</span>\n$ kubectl edit deployment nginx\n\n<span class=\"token comment\"># 编辑service类型的nginx的一些信息</span>\n$ kubectl edit service/nginx\n</code></pre>\n"}]}]},{"t":"heading","d":2,"p":{"lines":[162,163]},"v":"设置命令：label，annotate，completion","c":[{"t":"heading","d":3,"p":{"lines":[163,164]},"v":"<strong>label命令</strong>: 用于更新（增加、修改或删除）资源上的 label（标签）","c":[{"t":"bullet_list","d":4,"p":{"lines":[164,168]},"v":"","c":[{"t":"list_item","d":5,"p":{"lines":[164,165]},"v":"<code>label</code> 必须以字母或数字开头，可以使用字母、数字、连字符、点和下划线，最长63个字符。"},{"t":"list_item","d":5,"p":{"lines":[165,166]},"v":"如果 <code>--overwrite</code> 为 <code>true</code>，则可以覆盖已有的<code>label</code>，否则尝试覆盖<code>label</code>将会报错。"},{"t":"list_item","d":5,"p":{"lines":[166,167]},"v":"如果指定了<code>--resource-version</code>，则更新将使用此资源版本，否则将使用现有的资源版本。"}]},{"t":"blockquote","d":4,"p":{"lines":[168,169]},"v":"","c":[{"t":"paragraph","d":5,"p":{"lines":[168,169]},"v":"<code>语法</code>：label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]"}]},{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 给名为foo的Pod添加label unhealthy=true</span>\n$ kubectl label pods foo <span class=\"token assign-left variable\">unhealthy</span><span class=\"token operator\">=</span>true\n\n<span class=\"token comment\"># 给名为foo的Pod修改label 为 'status' / value 'unhealthy'，且覆盖现有的value</span>\n$ kubectl label --overwrite pods foo <span class=\"token assign-left variable\">status</span><span class=\"token operator\">=</span>unhealthy\n\n<span class=\"token comment\"># 给 namespace 中的所有 pod 添加 label</span>\n$ kubectl label  pods --all <span class=\"token assign-left variable\">status</span><span class=\"token operator\">=</span>unhealthy\n\n<span class=\"token comment\"># 仅当resource-version=1时才更新 名为foo的Pod上的label</span>\n$ kubectl label pods foo <span class=\"token assign-left variable\">status</span><span class=\"token operator\">=</span>unhealthy --resource-version<span class=\"token operator\">=</span><span class=\"token number\">1</span>\n\n<span class=\"token comment\"># 删除名为“bar”的label 。（使用“ - ”减号相连）</span>\n$ kubectl label pods foo bar-\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[188,189]},"v":"<strong>annotate命令</strong>：更新一个或多个资源的Annotations信息。也就是注解信息，可以方便的查看做了哪些操作。","c":[{"t":"bullet_list","d":4,"p":{"lines":[190,195]},"v":"","c":[{"t":"list_item","d":5,"p":{"lines":[190,191]},"v":"<code>Annotations</code>由key/value组成。"},{"t":"list_item","d":5,"p":{"lines":[191,192]},"v":"<code>Annotations</code>的目的是存储辅助数据，特别是通过工具和系统扩展操作的数据，更多介绍在<a href=\"https://links.jianshu.com/go?to=http%3A%2F%2Fdocs.kubernetes.org.cn%2F255.html\">这里</a>。"},{"t":"list_item","d":5,"p":{"lines":[192,193]},"v":"如果<code>--overwrite</code>为<code>true</code>，现有的<code>annotations</code>可以被覆盖，否则试图覆盖<code>annotations</code>将会报错。"},{"t":"list_item","d":5,"p":{"lines":[193,194]},"v":"如果设置了<code>--resource-version</code>，则更新将使用此<code>resource version</code>，否则将使用原有的<code>resource version</code>。"}]},{"t":"blockquote","d":4,"p":{"lines":[195,196]},"v":"","c":[{"t":"paragraph","d":5,"p":{"lines":[195,196]},"v":"<code>语法</code>：annotate [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]"}]},{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 更新Pod“foo”，设置annotation “description”的value “my frontend”，如果同一个annotation多次设置，则只使用最后设置的value值</span>\n$ kubectl annotate pods foo <span class=\"token assign-left variable\">description</span><span class=\"token operator\">=</span><span class=\"token string\">'my frontend'</span>\n\n<span class=\"token comment\"># 根据“pod.json”中的type和name更新pod的annotation</span>\n$ kubectl annotate -f pod.json <span class=\"token assign-left variable\">description</span><span class=\"token operator\">=</span><span class=\"token string\">'my frontend'</span>\n\n<span class=\"token comment\"># 更新Pod\"foo\"，设置annotation“description”的value“my frontend running nginx”，覆盖现有的值</span>\n$ kubectl annotate --overwrite pods foo <span class=\"token assign-left variable\">description</span><span class=\"token operator\">=</span><span class=\"token string\">'my frontend running nginx'</span>\n\n<span class=\"token comment\"># 更新 namespace中的所有pod</span>\n$ kubectl annotate pods --all <span class=\"token assign-left variable\">description</span><span class=\"token operator\">=</span><span class=\"token string\">'my frontend running nginx'</span>\n\n<span class=\"token comment\"># 只有当resource-version为1时，才更新pod 'foo'</span>\n$ kubectl annotate pods foo <span class=\"token assign-left variable\">description</span><span class=\"token operator\">=</span><span class=\"token string\">'my frontend running nginx'</span> --resource-version<span class=\"token operator\">=</span><span class=\"token number\">1</span>\n\n<span class=\"token comment\"># 通过删除名为“description”的annotations来更新pod 'foo'。</span>\n<span class=\"token comment\"># 不需要 -overwrite flag。</span>\n$ kubectl annotate pods foo description-\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[219,220]},"v":"<strong>completion命令</strong>：用于设置 kubectl 命令自动补全","c":[{"t":"fence","d":4,"v":"<pre><code>BASH\n</code></pre>\n"},{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 在 bash 中设置当前 shell 的自动补全，要先安装 bash-completion 包</span>\n$ <span class=\"token builtin class-name\">source</span> <span class=\"token operator\">&lt;</span><span class=\"token punctuation\">(</span>kubectl completion <span class=\"token function\">bash</span><span class=\"token punctuation\">)</span>\n\n<span class=\"token comment\"># 在您的 bash shell 中永久的添加自动补全</span>\n$ <span class=\"token builtin class-name\">echo</span> <span class=\"token string\">\"source &lt;(kubectl completion bash)\"</span> <span class=\"token operator\">>></span> ~/.bashrc \n</code></pre>\n"},{"t":"fence","d":4,"v":"<pre><code>ZSH\n</code></pre>\n"},{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 在 zsh 中设置当前 shell 的自动补全</span>\n$ <span class=\"token builtin class-name\">source</span> <span class=\"token operator\">&lt;</span><span class=\"token punctuation\">(</span>kubectl completion <span class=\"token function\">zsh</span><span class=\"token punctuation\">)</span>  \n\n<span class=\"token comment\"># 在您的 zsh shell 中永久的添加自动补全</span>\n$ <span class=\"token builtin class-name\">echo</span> <span class=\"token string\">\"if [ <span class=\"token variable\">$commands</span>[kubectl] ]; then source &lt;(kubectl completion zsh); fi\"</span> <span class=\"token operator\">>></span> ~/.zshrc \n</code></pre>\n"}]}]},{"t":"heading","d":2,"p":{"lines":[241,242]},"v":"kubectl 部署命令：rollout，rolling-update，scale，autoscale","c":[{"t":"heading","d":3,"p":{"lines":[243,244]},"v":"<strong>rollout 命令</strong>: 用于对资源进行管理","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\">可用资源包括：<span class=\"token variable\"><span class=\"token variable\">`</span>deployments<span class=\"token variable\">`</span></span>，<span class=\"token variable\"><span class=\"token variable\">`</span>daemonsets<span class=\"token variable\">`</span></span>。\n</code></pre>\n"},{"t":"heading","d":4,"p":{"lines":[247,248]},"v":"<code>子命令</code>：","c":[{"t":"list_item","d":6,"p":{"lines":[249,250]},"v":"<code>history</code>（查看历史版本）"},{"t":"list_item","d":6,"p":{"lines":[250,251]},"v":"<code>pause</code>（暂停资源）"},{"t":"list_item","d":6,"p":{"lines":[251,252]},"v":"<code>resume</code>（恢复暂停资源）"},{"t":"list_item","d":6,"p":{"lines":[252,253]},"v":"<code>status</code>（查看资源状态）"},{"t":"list_item","d":6,"p":{"lines":[253,254]},"v":"<code>undo</code>（回滚版本）"},{"t":"list_item","d":6,"p":{"lines":[254,255]},"v":"<code>restart</code> (重启某资源)"}]},{"t":"heading","d":4,"p":{"lines":[255,256]},"v":"语法","c":[{"t":"fence","d":5,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 语法</span>\n$ kubectl rollout SUBCOMMAND\n\n<span class=\"token comment\"># 回滚到之前的deployment</span>\n$ kubectl rollout undo deployment/abc\n\n<span class=\"token comment\"># 查看daemonet的状态</span>\n$ kubectl rollout status daemonset/foo\n</code></pre>\n"}]}]},{"t":"heading","d":3,"p":{"lines":[267,268]},"v":"<strong>rolling-update命令</strong>: 执行指定ReplicationController的滚动更新。","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\">该命令创建了一个新的<span class=\"token variable\"><span class=\"token variable\">`</span>RC<span class=\"token variable\">`</span></span>， 然后一次更新一个<span class=\"token variable\"><span class=\"token variable\">`</span>pod<span class=\"token variable\">`</span></span>方式逐步使用新的<span class=\"token variable\"><span class=\"token variable\">`</span>PodTemplate<span class=\"token variable\">`</span></span>，最终实现<span class=\"token variable\"><span class=\"token variable\">`</span>Pod<span class=\"token variable\">`</span></span>滚动更新，<span class=\"token variable\"><span class=\"token variable\">`</span>new-controller.json<span class=\"token variable\">`</span></span>需要与之前<span class=\"token variable\"><span class=\"token variable\">`</span>RC<span class=\"token variable\">`</span></span>在相同的<span class=\"token variable\"><span class=\"token variable\">`</span>namespace<span class=\"token variable\">`</span></span>下。\n</code></pre>\n"},{"t":"blockquote","d":4,"p":{"lines":[271,272]},"v":"","c":[{"t":"paragraph","d":5,"p":{"lines":[271,272]},"v":"<code>语法</code>：<code>rolling-update OLD_CONTROLLER_NAME ([NEW_CONTROLLER_NAME] --image=NEW_CONTAINER_IMAGE | -f NEW_CONTROLLER_SPEC)</code>"}]},{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 使用frontend-v2.json中的新RC数据更新frontend-v1的pod</span>\n$ kubectl rolling-update frontend-v1 -f frontend-v2.json\n\n<span class=\"token comment\"># 使用JSON数据更新frontend-v1的pod</span>\n$ <span class=\"token function\">cat</span> frontend-v2.json <span class=\"token operator\">|</span> kubectl rolling-update frontend-v1 -f -\n\n<span class=\"token comment\"># 其他的一些滚动更新</span>\n$ kubectl rolling-update frontend-v1 frontend-v2 --image<span class=\"token operator\">=</span>image:v2\n\n$ kubectl rolling-update frontend --image<span class=\"token operator\">=</span>image:v2\n\n$ kubectl rolling-update frontend-v1 frontend-v2 --rollback\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[288,289]},"v":"<strong>scale命令</strong>：扩容或缩容 <code>Deployment</code>、<code>ReplicaSet</code>、<code>Replication Controller</code>或 <code>Job</code> 中<code>Pod</code>数量","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token variable\"><span class=\"token variable\">`</span>scale<span class=\"token variable\">`</span></span>也可以指定多个前提条件，如：当前副本数量或 <span class=\"token variable\"><span class=\"token variable\">`</span>--resource-version<span class=\"token variable\">`</span></span> ，进行伸缩比例设置前，系统会先验证前提条件是否成立。这个就是弹性伸缩策略。\n</code></pre>\n"},{"t":"blockquote","d":4,"p":{"lines":[293,294]},"v":"","c":[{"t":"paragraph","d":5,"p":{"lines":[293,294]},"v":"<code>语法</code>：<code>kubectl scale [--resource-version=version] [--current-replicas=count] --replicas=COUNT (-f FILENAME | TYPE NAME)</code>"}]},{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 将名为foo中的pod副本数设置为3。</span>\n$ kubectl scale --replicas<span class=\"token operator\">=</span><span class=\"token number\">3</span> rs/foo\nkubectl scale deploy/nginx --replicas<span class=\"token operator\">=</span><span class=\"token number\">30</span>\n\n<span class=\"token comment\"># 将由“foo.yaml”配置文件中指定的资源对象和名称标识的Pod资源副本设为3</span>\n$ kubectl scale --replicas<span class=\"token operator\">=</span><span class=\"token number\">3</span> -f foo.yaml\n\n<span class=\"token comment\"># 如果当前副本数为2，则将其扩展至3。</span>\n$ kubectl scale --current-replicas<span class=\"token operator\">=</span><span class=\"token number\">2</span> --replicas<span class=\"token operator\">=</span><span class=\"token number\">3</span> deployment/mysql\n\n<span class=\"token comment\"># 设置多个RC中Pod副本数量</span>\n$ kubectl scale --replicas<span class=\"token operator\">=</span><span class=\"token number\">5</span> rc/foo rc/bar rc/baz\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[309,310]},"v":"<strong>autoscale命令</strong>：这个比<code>scale</code>更加强大，也是弹性伸缩策略 ，它是根据流量的多少来自动进行扩展或者缩容。","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\">指定<span class=\"token variable\"><span class=\"token variable\">`</span>Deployment<span class=\"token variable\">`</span></span>、<span class=\"token variable\"><span class=\"token variable\">`</span>ReplicaSet<span class=\"token variable\">`</span></span>或<span class=\"token variable\"><span class=\"token variable\">`</span>ReplicationController<span class=\"token variable\">`</span></span>，并创建已经定义好资源的自动伸缩器。使用自动伸缩器可以根据需要自动增加或减少系统中部署的pod数量。\n</code></pre>\n"},{"t":"blockquote","d":4,"p":{"lines":[314,315]},"v":"","c":[{"t":"paragraph","d":5,"p":{"lines":[314,315]},"v":"<code>语法</code>：<code>kubectl autoscale (-f FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] --max=MAXPODS [--cpu-percent=CPU] [flags]</code>"}]},{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 使用 Deployment “foo”设定，使用默认的自动伸缩策略，指定目标CPU使用率，使其Pod数量在2到10之间</span>\n$ kubectl autoscale deployment foo --min<span class=\"token operator\">=</span><span class=\"token number\">2</span> --max<span class=\"token operator\">=</span><span class=\"token number\">10</span>\n\n<span class=\"token comment\"># 使用RC“foo”设定，使其Pod的数量介于1和5之间，CPU使用率维持在80％</span>\n$ kubectl autoscale rc foo --max<span class=\"token operator\">=</span><span class=\"token number\">5</span> --cpu-percent<span class=\"token operator\">=</span><span class=\"token number\">80</span>\n</code></pre>\n"}]}]},{"t":"heading","d":2,"p":{"lines":[324,325]},"v":"集群管理命令：certificate，cluster-info，top，cordon，uncordon，drain，taint","c":[{"t":"heading","d":3,"p":{"lines":[326,327]},"v":"<strong>certificate命令</strong>：用于证书资源管理，授权等","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 例如，当有node节点要向master请求，那么是需要master节点授权的</span>\n$ kubectl certificate approve node-csr-81F5uBehyEyLWco5qavBsxc1GzFcZk3aFM3XW5rT3mw node-csr-Ed0kbFhc_q7qx14H3QpqLIUs0uKo036O2SnFpIheM18\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[332,333]},"v":"<strong>cluster-info 命令</strong>：显示集群信息","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\">$ kubectl cluster-info\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[337,338]},"v":"<strong>top 命令</strong>：用于查看资源的cpu，内存磁盘等资源的使用率","c":[{"t":"fence","d":4,"v":"<pre class=\"language-ruby\"><code class=\"language-ruby\"><span class=\"token comment\"># 以前需要heapster，后替换为metrics-server</span>\n$ kubectl top pod <span class=\"token operator\">--</span>all<span class=\"token operator\">-</span>namespaces\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[342,343]},"v":"<strong>cordon命令</strong>：用于标记某个节点不可调度"},{"t":"heading","d":3,"p":{"lines":[344,345]},"v":"<strong>uncordon命令</strong>：用于标签节点可以调度"},{"t":"heading","d":3,"p":{"lines":[346,347]},"v":"<strong>drain命令</strong>： 用于在维护期间排除节点。"},{"t":"heading","d":3,"p":{"lines":[348,349]},"v":"<strong>taint命令</strong>：用于给某个<code>Node</code>节点设置污点"}]},{"t":"heading","d":2,"p":{"lines":[350,351]},"v":"集群故障排查和调试命令：describe，logs，exec，attach，port-foward，proxy，cp，auth","c":[{"t":"heading","d":3,"p":{"lines":[352,353]},"v":"<strong>describe命令</strong>：显示特定资源的详细信息","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 查看my-nginx pod的详细状态</span>\n$ kubectl describe po my-nginx\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[357,358]},"v":"<strong>logs命令</strong>：用于在一个pod中打印一个容器的日志，如果pod中只有一个容器，可以省略容器名","c":[{"t":"blockquote","d":4,"p":{"lines":[359,360]},"v":"","c":[{"t":"paragraph","d":5,"p":{"lines":[359,360]},"v":"<code>语法</code>：<code>kubectl logs [-f] [-p] POD [-c CONTAINER]</code>"}]},{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 返回仅包含一个容器的pod nginx的日志快照</span>\n$ kubectl logs nginx\n\n<span class=\"token comment\"># 返回pod ruby中已经停止的容器web-1的日志快照</span>\n$ kubectl logs -p -c ruby web-1\n\n<span class=\"token comment\"># 持续输出pod ruby中的容器web-1的日志</span>\n$ kubectl logs -f -c ruby web-1\n\n<span class=\"token comment\"># 仅输出pod nginx中最近的20条日志</span>\n$ kubectl logs --tail<span class=\"token operator\">=</span><span class=\"token number\">20</span> nginx\n\n<span class=\"token comment\"># 输出pod nginx中最近一小时内产生的所有日志</span>\n$ kubectl logs --since<span class=\"token operator\">=</span>1h nginx\n</code></pre>\n"},{"t":"bullet_list","d":4,"p":{"lines":[380,390]},"v":"","c":[{"t":"list_item","d":5,"p":{"lines":[380,381]},"v":"-c, --container=&quot;&quot;: 容器名。"},{"t":"list_item","d":5,"p":{"lines":[381,382]},"v":"-f, --follow[=false]: 指定是否持续输出日志（实时日志）。"},{"t":"list_item","d":5,"p":{"lines":[382,383]},"v":"--interactive[=true]: 如果为true，当需要时提示用户进行输入。默认为true。"},{"t":"list_item","d":5,"p":{"lines":[383,384]},"v":"--limit-bytes=0: 输出日志的最大字节数。默认无限制。"},{"t":"list_item","d":5,"p":{"lines":[384,385]},"v":"-p, --previous[=false]: 如果为true，输出pod中曾经运行过，但目前已终止的容器的日志。"},{"t":"list_item","d":5,"p":{"lines":[385,386]},"v":"--since=0: 仅返回相对时间范围，如5s、2m或3h，之内的日志。默认返回所有日志。只能同时使用since和since-time中的一种。"},{"t":"list_item","d":5,"p":{"lines":[386,387]},"v":"--since-time=&quot;&quot;: 仅返回指定时间（RFC3339格式）之后的日志。默认返回所有日志。只能同时使用since和since-time中的一种。"},{"t":"list_item","d":5,"p":{"lines":[387,388]},"v":"--tail=-1: 要显示的最新的日志条数。默认为-1，显示所有的日志。"},{"t":"list_item","d":5,"p":{"lines":[388,389]},"v":"--timestamps[=false]: 在日志中包含时间戳。"}]}]},{"t":"heading","d":3,"p":{"lines":[390,391]},"v":"<strong>exec命令</strong>：进入容器进行交互，在容器中执行命令","c":[{"t":"blockquote","d":4,"p":{"lines":[392,393]},"v":"","c":[{"t":"paragraph","d":5,"p":{"lines":[392,393]},"v":"<code>语法</code>：kubectl exec POD [-c CONTAINER] -- COMMAND [args...]"}]},{"t":"bullet_list","d":4,"p":{"lines":[396,401]},"v":"","c":[{"t":"list_item","d":5,"p":{"lines":[396,397]},"v":"-c, --container=&quot;&quot;: 容器名。如果未指定，使用pod中的一个容器。"},{"t":"list_item","d":5,"p":{"lines":[397,398]},"v":"-p, --pod=&quot;&quot;: Pod名。"},{"t":"list_item","d":5,"p":{"lines":[398,399]},"v":"-i, --stdin[=false]: 将控制台输入发送到容器。"},{"t":"list_item","d":5,"p":{"lines":[399,400]},"v":"-t, --tty[=false]: 将标准输入控制台作为容器的控制台输入。"}]},{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 进入nginx容器，执行一些命令操作</span>\n$ kubectl <span class=\"token builtin class-name\">exec</span> -it nginx-deployment-58d6d6ccb8-lc5fp <span class=\"token function\">bash</span>\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[406,407]},"v":"<strong>attach命令</strong>：连接到一个正在运行的容器。","c":[{"t":"blockquote","d":4,"p":{"lines":[408,409]},"v":"","c":[{"t":"paragraph","d":5,"p":{"lines":[408,409]},"v":"<code>语法</code>：<code>kubectl attach POD -c CONTAINER</code>"}]},{"t":"bullet_list","d":4,"p":{"lines":[412,416]},"v":"","c":[{"t":"list_item","d":5,"p":{"lines":[412,413]},"v":"-c, --container=&quot;&quot;: 容器名。如果省略，则默认选择第一个 pod。"},{"t":"list_item","d":5,"p":{"lines":[413,414]},"v":"-i, --stdin[=false]: 将控制台输入发送到容器。"},{"t":"list_item","d":5,"p":{"lines":[414,415]},"v":"-t, --tty[=false]: 将标准输入控制台作为容器的控制台输入。"}]},{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 获取正在运行中的pod 123456-7890的输出，默认连接到第一个容器</span>\n$ kubectl attach <span class=\"token number\">123456</span>-7890\n\n<span class=\"token comment\"># 获取pod 123456-7890中ruby-container的输出</span>\n$ kubectl attach <span class=\"token number\">123456</span>-7890 -c ruby-container\n\n<span class=\"token comment\"># 切换到终端模式，将控制台输入发送到pod 123456-7890的ruby-container的“bash”命令，并将其输出到控制台/</span>\n<span class=\"token comment\"># 错误控制台的信息发送回客户端。</span>\n$ kubectl attach <span class=\"token number\">123456</span>-7890 -c ruby-container -i -t\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[427,428]},"v":"<strong>cp命令</strong>：拷贝文件或者目录到pod容器中"}]},{"t":"heading","d":2,"p":{"lines":[431,432]},"v":"其他命令：api-servions，config，help，plugin，version","c":[{"t":"heading","d":3,"p":{"lines":[433,434]},"v":"<strong>api-servions命令</strong>：打印受支持的<code>api</code>版本信息","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 打印当前集群支持的api版本</span>\n$ kubectl api-versions\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[438,439]},"v":"<strong>help命令</strong>：用于查看命令帮助","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 显示全部的命令帮助提示</span>\n$ kubectl --help\n\n<span class=\"token comment\"># 具体的子命令帮助，例如</span>\n$ kubectl create --help\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[447,448]},"v":"<strong>config 命令</strong>: 用于修改<code>kubeconfig</code>配置文件（用于访问api，例如配置认证信息）","c":[{"t":"fence","d":4,"v":"<pre class=\"language-shell\"><code class=\"language-shell\">设置 <span class=\"token variable\"><span class=\"token variable\">`</span>kubectl<span class=\"token variable\">`</span></span> 与哪个 <span class=\"token variable\"><span class=\"token variable\">`</span>Kubernetes<span class=\"token variable\">`</span></span> 集群进行通信并修改配置信息。\n</code></pre>\n"},{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 显示合并的 kubeconfig 配置</span>\n$ kubectl config view\n\n<span class=\"token comment\"># 同时使用多个 kubeconfig 文件并查看合并的配置</span>\n$ <span class=\"token assign-left variable\">KUBECONFIG</span><span class=\"token operator\">=</span>~/.kube/config:~/.kube/kubconfig2 kubectl config view\n\n<span class=\"token comment\"># 获取 e2e 用户的密码</span>\n$ kubectl config view -o <span class=\"token assign-left variable\">jsonpath</span><span class=\"token operator\">=</span><span class=\"token string\">'{.users[?(@.name == \"e2e\")].user.password}'</span>\n\n<span class=\"token comment\"># 展示当前所处的上下文</span>\n$ kubectl config current-context\n\n<span class=\"token comment\"># 设置默认的上下文为 my-cluster-name</span>\n$ kubectl config use-context my-cluster-name\n\n<span class=\"token comment\"># 添加新的集群配置到 kubeconf 中，使用 basic auth 进行鉴权</span>\n$ kubectl config set-credentials kubeuser/foo.kubernetes.com --username<span class=\"token operator\">=</span>kubeuser --password<span class=\"token operator\">=</span>kubepassword\n\n<span class=\"token comment\"># 使用特定的用户名和命名空间设置上下文。</span>\n$ kubectl config set-context gce --user<span class=\"token operator\">=</span>cluster-admin --namespace<span class=\"token operator\">=</span>foo <span class=\"token punctuation\">\\</span>\n  <span class=\"token operator\">&amp;&amp;</span> kubectl config use-context gce\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[475,476]},"v":"<strong>version 命令</strong>：打印客户端和服务端版本信息","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 打印客户端和服务端版本信息</span>\n$ kubectl version\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[481,482]},"v":"<strong>plugin 命令</strong>：运行一个命令行插件"}]},{"t":"heading","d":2,"p":{"lines":[483,484]},"v":"高级命令：apply，patch，replace，convert","c":[{"t":"heading","d":3,"p":{"lines":[485,486]},"v":"<strong>apply命令</strong>：通过文件名或者标准输入对资源应用配置","c":[{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\">通过文件名或控制台输入，对资源进行配置。 如果资源不存在，将会新建一个。可以使用 <span class=\"token variable\"><span class=\"token variable\">`</span>JSON<span class=\"token variable\">`</span></span> 或者 <span class=\"token variable\"><span class=\"token variable\">`</span>YAML<span class=\"token variable\">`</span></span> 格式。`\n</code></pre>\n"},{"t":"blockquote","d":4,"p":{"lines":[489,490]},"v":"","c":[{"t":"paragraph","d":5,"p":{"lines":[489,490]},"v":"<code>语法</code>：<code>kubectl apply -f FILENAME</code>"}]},{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># 将pod.json中的配置应用到pod</span>\n$ kubectl apply -f ./pod.json\n\n<span class=\"token comment\"># 将控制台输入的JSON配置应用到Pod</span>\n$ <span class=\"token function\">cat</span> pod.json <span class=\"token operator\">|</span> kubectl apply -f -\n</code></pre>\n"},{"t":"bullet_list","d":4,"p":{"lines":[499,509]},"v":"","c":[{"t":"list_item","d":5,"p":{"lines":[499,500]},"v":"<code>参数选项</code>：","c":[{"t":"list_item","d":7,"p":{"lines":[501,502]},"v":"-f, --filename=[]: 包含配置信息的文件名，目录名或者URL。"},{"t":"list_item","d":7,"p":{"lines":[502,503]},"v":"--include-extended-apis[=true]: If true, include definitions of new APIs via calls to the API server. [default true]"},{"t":"list_item","d":7,"p":{"lines":[503,504]},"v":"-o, --output=&quot;&quot;: 输出模式。&quot;-o name&quot;为快捷输出(资源/name)."},{"t":"list_item","d":7,"p":{"lines":[504,505]},"v":"--record[=false]: 在资源注释中记录当前 kubectl 命令。"},{"t":"list_item","d":7,"p":{"lines":[505,506]},"v":"-R, --recursive[=false]: Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory."},{"t":"list_item","d":7,"p":{"lines":[506,507]},"v":"--schema-cache-dir=&quot;~/.kube/schema&quot;: 非空则将API schema缓存为指定文件，默认缓存到'$HOME/.kube/schema'"},{"t":"list_item","d":7,"p":{"lines":[507,508]},"v":"--validate[=true]: 如果为true，在发送到服务端前先使用schema来验证输入。"}]}]}]},{"t":"heading","d":3,"p":{"lines":[509,510]},"v":"<strong>patch命令</strong>：使用补丁修改，更新资源的字段，也就是修改资源的部分内容","c":[{"t":"blockquote","d":4,"p":{"lines":[511,512]},"v":"","c":[{"t":"paragraph","d":5,"p":{"lines":[511,512]},"v":"<code>语法</code>：<code>kubectl patch (-f FILENAME | TYPE NAME) -p PATCH</code>"}]},{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># Partially update a node using strategic merge patch</span>\n$ kubectl patch node k8s-node-1 -p <span class=\"token string\">'{\"spec\":{\"unschedulable\":true}}'</span>\n\n<span class=\"token comment\"># Update a container's image; spec.containers[*].name is required because it's a merge key</span>\n$ kubectl patch pod valid-pod -p <span class=\"token string\">'{\"spec\":{\"containers\":[{\"name\":\"kubernetes-serve-hostname\",\"image\":\"new image\"}]}}'</span>\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[520,521]},"v":"<strong>replace命令</strong>： 通过文件或者标准输入替换原有资源","c":[{"t":"blockquote","d":4,"p":{"lines":[522,523]},"v":"","c":[{"t":"paragraph","d":5,"p":{"lines":[522,523]},"v":"<code>语法</code>：<code>kubectl replace -f FILENAME</code>"}]},{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># Replace a pod using the data in pod.json.</span>\n$ kubectl replace -f ./pod.json\n\n<span class=\"token comment\"># Replace a pod based on the JSON passed into stdin.</span>\n$ <span class=\"token function\">cat</span> pod.json <span class=\"token operator\">|</span> kubectl replace -f -\n\n<span class=\"token comment\"># Update a single-container pod's image version (tag) to v4</span>\n$ kubectl get pod mypod -o yaml <span class=\"token operator\">|</span> <span class=\"token function\">sed</span> <span class=\"token string\">'s/\\(image: myimage\\):.*$/<span class=\"token entity\" title=\"\\1\">\\1</span>:v4/'</span> <span class=\"token operator\">|</span> kubectl replace -f -\n\n<span class=\"token comment\"># Force replace, delete and then re-create the resource</span>\n$ kubectl replace --force -f ./pod.json\n</code></pre>\n"}]},{"t":"heading","d":3,"p":{"lines":[537,538]},"v":"<strong>convert命令</strong>：不同的版本之间转换配置文件","c":[{"t":"blockquote","d":4,"p":{"lines":[539,540]},"v":"","c":[{"t":"paragraph","d":5,"p":{"lines":[539,540]},"v":"<code>语法</code>：<code>kubectl convert -f FILENAME</code>"}]},{"t":"fence","d":4,"v":"<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># Convert 'pod.yaml' to latest version and print to stdout.</span>\n$ kubectl convert -f pod.yaml\n\n<span class=\"token comment\"># Convert the live state of the resource specified by 'pod.yaml' to the latest version</span>\n<span class=\"token comment\"># and print to stdout in json format.</span>\n$ kubectl convert -f pod.yaml --local -o json\n\n<span class=\"token comment\"># Convert all files under current directory to latest version and create them all.</span>\n$ kubectl convert -f <span class=\"token builtin class-name\">.</span> <span class=\"token operator\">|</span> kubectl create -f -\n</code></pre>\n"}]}]},{"t":"heading","d":2,"p":{"lines":[553,554]},"v":"格式化输出","c":[{"t":"list_item","d":4,"p":{"lines":[558,559]},"v":"-o=custom-columns=<spec>  根据自定义列名进行输出，以逗号分隔"},{"t":"list_item","d":4,"p":{"lines":[559,560]},"v":"-o=custom-colimns-file=<filename> 从文件中获取自定义列名进行输出"},{"t":"list_item","d":4,"p":{"lines":[560,561]},"v":"-o=json   以JSON格式显示结果"},{"t":"list_item","d":4,"p":{"lines":[561,562]},"v":"-o=jsonpath=<template>    输出jsonpath表达式定义的字段信息"},{"t":"list_item","d":4,"p":{"lines":[562,563]},"v":"-o=jsonpath-file=<filename>   输出jsonpath表达式定义的字段信息，来源于文件"},{"t":"list_item","d":4,"p":{"lines":[563,564]},"v":"-o=name   仅输出资源对象的名称"},{"t":"list_item","d":4,"p":{"lines":[564,565]},"v":"-o=wide   输出额外信息。对于Pod，将输出Pod所在的Node名"},{"t":"list_item","d":4,"p":{"lines":[565,566]},"v":"-o=yaml   以yaml格式显示结果"}]},{"t":"heading","d":2,"p":{"lines":[567,568]},"v":"Kubectl 日志输出详细程度和调试","c":[{"t":"list_item","d":4,"p":{"lines":[570,571]},"v":"-o=custom-columns=<spec>  根据自定义列名进行输出，以逗号分隔"},{"t":"list_item","d":4,"p":{"lines":[571,572]},"v":"-o=custom-colimns-file=<filename> 从文件中获取自定义列名进行输出"},{"t":"list_item","d":4,"p":{"lines":[572,573]},"v":"-o=json   以JSON格式显示结果"},{"t":"list_item","d":4,"p":{"lines":[573,574]},"v":"-o=jsonpath=<template>    输出jsonpath表达式定义的字段信息"},{"t":"list_item","d":4,"p":{"lines":[574,575]},"v":"-o=jsonpath-file=<filename>   输出jsonpath表达式定义的字段信息，来源于文件"},{"t":"list_item","d":4,"p":{"lines":[575,576]},"v":"-o=name   仅输出资源对象的名称"},{"t":"list_item","d":4,"p":{"lines":[576,577]},"v":"-o=wide   输出额外信息。对于Pod，将输出Pod所在的Node名"},{"t":"list_item","d":4,"p":{"lines":[577,578]},"v":"-o=yaml   以yaml格式显示结果"}]}]})</script>
</body>
</html>
